using UnityEditor;
using UnityEngine;

namespace UFrame
{

    /// <summary>
    /// 
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public abstract class BaseEditorArea<T> where T : EditorWindow
    {
        protected Rect rect;
        protected T root;

        public BaseEditorArea(T t, float x, float y, float width, float height)
        {
            root = t;
            ResetArea(x, y, width, height);
        }

        public void ResetArea(float x, float y, float width, float height)
        {
            rect = new Rect(x, y, width, height);
        }

        public abstract void DrawArea();

        public abstract void OnEditorEvent(IEditorEvent e);

    }

    public interface IEditorEvent
    {
        int GetEventID();
        object GetEventData();
    }

    public class EditorEvent<T> : IEditorEvent where T : new()
    {

        protected int eventID;
        protected T obj;
        public EditorEvent()
        {
            obj = new T();
        }
        public int EventID
        {
            get
            {
                return eventID;
            }
            set
            {
                eventID = value;
            }
        }
        public T EventData
        {
            get
            {
                return obj;
            }
        }

        public int GetEventID()
        {
            return eventID;
        }

        public object GetEventData()
        {
            return obj;
        }
    }

    public class SkillEditorEvent<T> : EditorEvent<T> where T : new()
    {
        public SkillTestEditorEventEnum EnumValue
        {
            set
            {

                eventID = (int)value;
            }
            get
            {
                return (SkillTestEditorEventEnum)eventID;
            }
        }
    }



}